<template>
    <div class="major-box">
        <div class="table-area">
            <el-table ref="multipleTableRef" :data="book" style="width: 100%" @selection-change="handleSelectionChange" >
                <el-table-column prop="name" label="教材名称">
                    <template #default="scope">
                        <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top-start" > <div class="text">{{ scope.row.title }}</div> </el-tooltip>
                    </template>
                </el-table-column>
                <el-table-column prop="type" label="教材/图书类型" />
                <el-table-column prop="isbn" label="ISBN码" />
                <el-table-column prop="knowledge" label="知识点" />
                <el-table-column prop="relationship" label="关系" />
                <el-table-column prop="status" label="状态" />
                <el-table-column property="name" label="操作" align="center" width="150">
                    <template #default="scope">
                        <div class="material-operations">
                            <el-link type="primary"  @click="graphView(scope.row)" :underline="false">书籍图谱</el-link>
                            <el-link type="primary"  @click="preview(scope.row)" :underline="false">更多</el-link>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pages">
                <el-pagination small background layout="prev, pager, next" :total="50" class="mt-4" />
            </div>
        </div>
    </div>
    <el-dialog v-model="addTeacherDialogVisable" title="Tips" width="35%" top="25vh">
        <template #header>
            <div class="my-header">
                <span>新建专业</span>
            </div>
        </template>
        <div class="import-dialog">
            <div class="add-form">
                <div class="items" style="flex: 0 0 100%;">
                    <div class="text" style="flex: 0 0 100px;">教师/职称</div>
                    <el-select v-model="value" class="m-2" placeholder="请选择教师" style="width: 100%;">
                        <el-option :key="o" label="计算机教师/正高级教师" value="计算机教师/正高级教师" v-for="o in 6" />
                    </el-select>
                </div>
            </div>
        </div>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="addTeacher()">取消</el-button>
                <el-button type="primary" @click="addTeacher()">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script setup>
    import { ref,defineEmits } from 'vue'
    import '@wangeditor/editor/dist/css/style.css'

    const addTeacherDialogVisable = ref(false);
    const book = ref([
        {
            title: '标准日语（初级下册）',
            type: '公开标准教材',
            isbn: '9787107185069',
            permission: '完全公开',
            knowledge: '369',
            relationship: '269',
            status: '生成完成',
        },
        {
            title: '标准日语（初级上册）',
            type: '公开标准教材',
            isbn: '7107108654',
            permission: '完全公开',
            knowledge: '263',
            relationship: '184',
            status: '生成完成',
        },
        {
            title: '信号与系统',
            type: '公开标准教材',
            isbn: '9787111759775',
            permission: '完全公开',
            knowledge: '95',
            relationship: '78',
            status: '生成中',
        },
        {
            title: 'Java程序语言设计课程标准',
            type: '公开标准教材',
            isbn: '7843954512',
            permission: '完全公开',
            knowledge: '168',
            relationship: '175',
            status: '生成中',
        },
        {
            title: '模拟电路与数字电路',
            type: '公开标准教材',
            isbn: '5675869783233',
            permission: '完全公开',
            knowledge: '1335',
            relationship: '1350',
            status: '生成完成',
        },
        {
            title: '物联网综合设计',
            type: '公开标准教材',
            isbn: '5675869783233',
            permission: '完全公开',
            knowledge: '1335',
            relationship: '1350',
            status: '生成完成',
        },
        {
            title: '传感器原理与应用',
            type: '公开标准教材',
            isbn: '1234567893',
            permission: '完全公开',
            knowledge: '94',
            relationship: '1350',
            status: '生成完成',
        },
        {
            title: '国家安全教育大学生读本',
            type: '公开标准教材',
            isbn: '1234567893',
            permission: '完全公开',
            knowledge: '94',
            relationship: '1350',
            status: '生成完成',
        },
    ]);
    const addTeacher = () => {
        addTeacherDialogVisable.value = !addTeacherDialogVisable.value
    }
    const emit = defineEmits(['update-show-visable'])
    const graphView = () => {
        emit('update-show-visable', true);
    }
</script>
<style scoped>
    :deep(.el-input__wrapper){background: #F2F3FA!important;}
    :deep(.el-table__row:nth-child(odd)){background: #ffffff!important;}
    :deep(.el-table__row:nth-child(even)){background: #F5F8FE!important;}
    :deep(.el-table th.el-table__cell) { background-color: #D2E3FB; }
    :deep(.el-input) { width: 100%;height: 35px; }
    :deep(.search-item .el-input) { flex: 0 0 200px;height: 35px; }
    :deep(.el-select) { flex: 0 0 200px;height: 35px; }
    :deep(.el-select__wrapper) { height: 35px; }
    :deep(.dialog-footer span) { font-family: 微软雅黑, Microsoft YaHei, SimSun;font-size: 12px!important; }
    .major-box{background: #fff;width: 100%;height: 100%;height: calc(85vh - 20px);}
    .search-row { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 15px;background: #fff;padding: 20px;border-radius: 8px;justify-content: space-between; }
    .search-item { display: flex;flex-direction: row;gap: 20px; }
    .el-button:hover{color: #1465E1!important;border: 1px solid #1465E1;}
    .el-button--primary{background: #1465E1!important;border: 1px solid #1465E1;}
    .el-button--primary:hover{color: #fff!important;}
    .table-area { background: white; border-radius: 4px; padding: 20px; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05); }
    .table-area .text{ width: 100%;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;font-size: 14px;font-family: 微软雅黑, Microsoft YaHei, SimSun; }
    .pages{display: flex;flex-direction: row;justify-content: end;padding-top: 30px;}
    .material-operations{display: flex;justify-content: space-around;font-family: 微软雅黑, Microsoft YaHei, SimSun;}
    .material-operations span{font-size: 12px!important;}
    .material-operations span:hover{color: #1465E1;}
    .material-operations .danger:hover{color: red;}
    .add-major{width: 120px;background: #1465E1;height: 35px;display: flex;flex-direction: row;align-items: center;justify-content: center;border-radius: 4px;margin-bottom: 20px;cursor: pointer;}
    .add-major img{width: 20px;height: 20px;}
    .add-major span{margin-left: 5px;font-family: 微软雅黑, Microsoft YaHei, SimSun;color: #fff;font-size: 14px;}
    .my-header{text-align: left;}
    .add-form{ width: calc(100% - 30px);margin: 10px auto;display: flex;flex-direction: row; gap: 20px; }
    .form-item{flex: 1;}
    .add-form .items{display: flex;flex-direction: row;gap: 5px;align-items: center;}
    .add-form .items .reds{ color: red; }
    .add-form .inputs{ margin-top: 10px; }
    .left-buttons { display: flex;padding: 20px 0 20px 20px; }
    .left-buttons .manage{color: #1465E1;height: 35px;border: 1px solid #1465E1;}
    .class-switch{position: relative;}
    .class-switch .switch-item { cursor: pointer; position: relative; transition: color 0.3s ease; text-align: center; color: #7f8c8d;z-index: 2; }
    .slider { border-radius: 35px; height: 35px; background: #3869E7; z-index: 1; transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55); position: absolute; top: 0; }
    .switch-item.active { color: white; }
    .mode-1 { background: #1465E1; }
    .mode-2 { background: #1465E1; }
    .form-item .class-switch{display: flex;flex-direction: row;width: 100%;background: #F7F7F7;border-radius: 40px;margin-top: 10px;}
    .form-item .class-switch .switch-item{width: 50%;height: 35px;line-height: 35px;}
    .left-item{display: flex;flex-direction: row; flex: 0 0 49%;gap: 10px;}
    .avatar-uploader .avatar { width: 178px; height: 178px; display: block; }
    :deep(.avatar-uploader) { display: flex;flex-direction: row;justify-content: start; }
    :deep(.avatar-uploader .el-upload) { border: 1px dashed var(--el-border-color); border-radius: 6px; cursor: pointer; position: relative; overflow: hidden; transition: var(--el-transition-duration-fast); }
    :deep(.avatar-uploader .el-upload:hover) { border-color: var(--el-color-primary); }
    :deep(.el-icon.avatar-uploader-icon) { font-size: 28px; color: #8c939d; width: 178px; height: 178px; text-align: center; }
    .import-dialog .add-form{margin-top: 20px;}
</style>